package gupao.concurrency.forecaster;

import gupao.concurrency.enums.TrafficChannelEnum;
import gupao.concurrency.service.ForcastConfigService;
import gupao.concurrency.service.TrafficForecastService;
import gupao.concurrency.threadpool.ForecastScheduledExecutor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.ScheduledThreadPoolExecutor;

@Configuration
public class ForcastConfiguration {

    @Bean
    public ForecastScheduledExecutor forcastScheduledExecutor(ForcastConfigService configService,
                                                              TrafficForecastService forcasterService){
        return new ForecastScheduledExecutor(2, configService, forcasterService);
    }

    @Bean
    public ChannelForcaster defaultChannelForcaster(ForecastScheduledExecutor scheduler, ForcastConfigService configService){
        return new ChannelForcaster(TrafficChannelEnum.DEFAULT,scheduler, configService);
    }

    @Bean
    public ScheduledThreadPoolExecutor scheduledExecutorService() {
        ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(10);
        return executor;
    }
}
